import { View } from "../../../../mvc/core/View";
import { Language } from "../../../../../extend/language/Language";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { EventName } from "../../../mvc/EventName";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { EColor } from "../../../../../Message/Public/EColor";
import { MountExtendAlertWindow } from "../mount/MountExtendAlertWindow";
import { Cache } from "../../../cache/Cache";
import { ObjCreate } from "../../common/ObjCreate";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { BaseItem } from "../../common/BaseItem";
import { DragEvent } from "../../../../../com/mui/events/DragEvent";
import { MountComboBoxItemCellRender } from "../cell/MountComboBoxItemCellRender";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { FlowerBg } from "../../common/FlowerBg";
import { PublicMessageConfig } from "../../../resource/PublicMessageConfig";
import { GScrollPane } from "../../../../../com/mui/controls/GScrollPane";
import { ScrollPolicy } from "../../../../../fl/controls/ScrollPolicy";
import { PetProcessBar } from "../../pet/PetProcessBar";
import { ResouceConst } from "../../../../component/gconst/ResouceConst";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { ItemData } from "../../../resource/info/ItemData";
import { MountConfig } from "../../../resource/MountConfig";
import { MsgManager } from "../../../manager/MsgManager";
import { EPlayerItemPosType } from "../../../../../Message/Public/EPlayerItemPosType";
import { ItemsUtil } from "../../shortcuts/item/ItemsUtil";
import { Global } from "../../../../../com/gengine/global/Global";
import { GButton } from "../../../../../com/mui/controls/GButton";
import { Alert } from "../../../../../com/mui/controls/Alert";
import { DataProvider } from "../../../../../fl/data/DataProvider";
import { GComboBox } from "../../../../../com/mui/controls/GComboBox";
import { ColorConfig } from "../../../resource/ColorConfig";
import { TextAlign } from "../../../../../flashx/textLayout/formats/TextAlign";
import { DataEvent } from "../../../events/DataEvent";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { GameManager } from "../../../manager/GameManager";
import { ModuleType } from "../../common/ModuleType";
import { GCheckBox } from "../../../../../com/mui/controls/GCheckBox";
import { GLabel } from "../../../../../com/mui/controls/GLabel";
import { MountGrowBars } from "../mount/MountGrowBars";
type int = number;
//class MountExtendPanel
    
    export  class MountExtendPanel extends View
    {
        constructor()
        {
            super();
            this._arrBaseValue = [];
            this._growStartArr = [];
            this._growForsterArr = [];
            this._arrAttrGrow = Language.getString(70009).split(",");
            this.initView();
            Dispatcher.addEventListener(EventName.MountExtendSuccess, this.onClear);
            return;
        }

        /* internal  */onLoadBmResource(): void
        {
            this._stBmMountExtendBg.bitmapData = GlobalClass.getBitmapData(ImagesConst.mountExtendBg);
            this._stBmMountBeforExtend.bitmapData = GlobalClass.getBitmapData(ImagesConst.mountBeforExtend);
            this._stBmMoungtGrow.bitmapData = GlobalClass.getBitmapData(ImagesConst.moungtGrow);
            this._stBmMountAddAtrr.bitmapData = GlobalClass.getBitmapData(ImagesConst.mountAddAtrr);
            this._stBmMountBaseAtrr.bitmapData = GlobalClass.getBitmapData(ImagesConst.mountBaseAtrr);
            return;
        }

        /* internal  */toAlertExtend(): void
        {
            if (this._deputyMountInfo.color >= EColor._EColorPurple) 
            {
                MountExtendAlertWindow.instance.mode = MountExtendAlertWindow.ValidateMode;
            }
            else 
            {
                MountExtendAlertWindow.instance.mode = MountExtendAlertWindow.NormalMode;
            }
            if (this._collectValueIsUp) 
            {
                MountExtendAlertWindow.instance.txTips = Language.getString(70207);
                MountExtendAlertWindow.instance.huanLv = parseInt(this._txHuanLv.text) - this._mainMountInfo.itemExInfo.m_change_lv;
            }
            else 
            {
                MountExtendAlertWindow.instance.txTips = Language.getString(70206);
                MountExtendAlertWindow.instance.huanLv = 0;
            }
            MountExtendAlertWindow.instance.mainInfo = this._mainMountInfo;
            MountExtendAlertWindow.instance.deputyInfo = this._deputyMountInfo;
            MountExtendAlertWindow.instance.growthSelect = this._selectedNum;
            MountExtendAlertWindow.instance.show();
            return;
        }

        /* internal  */initView(): void
        {
            var loc3=null;
            var loc4=null;
            var loc5=null;
            var loc18=null;
            var loc19=null;
            var loc20=null;
            var loc21=null;
            var loc22=null;
            this.dpMian = this.getMountComboDp(Cache.instance.pack.mountsPackCache.getMountArrayFromPack(), true);
            this.dpDeput = this.getMountComboDp(Cache.instance.pack.mountsPackCache.getMountArrayFromPack(), false);
            ObjCreate.createFlowerBg(0, 0, 322, 320, this);
            this._stBmMountExtendBg = ObjCreate.createBitmap("", 50, 78, this);
            ObjCreate.createTextField(Language.getString(70082), 52, 10, 70, 30, this, new GTextFormat(FontUtil.songtiName, 14, 15788607, true));
            ObjCreate.createBg(57, 34, 38, 38, this, ImagesConst.PackItemBg);
            this._mainMountItem = new BaseItem();
            this._mainMountItem.posIndex = 1;
            this._mainMountItem.setSize(32, 32);
            this._mainMountItem.move(60, 37);
            this._mainMountItem.addEventListener(DragEvent.Event_Move_In, this.onMainMoveInMountHandler);
            this._mainMountItem.addEventListener(flash.events.MouseEvent.CLICK, this.onMainMountItemClickHandler);
            this.addChild(this._mainMountItem);
            this._mainMountComboBox = ObjCreate.createGComboBox(24, 77, 105, 25, this.dpMian, this);
            this._mainMountComboBox.selectedIndex = -1;
            this._mainMountComboBox.prompt = Language.getString(70087);
            this._mainMountComboBox.dropdown.setStyle("cellRenderer", MountComboBoxItemCellRender);
            this._mainMountComboBox.addEventListener(flash.events.Event.CHANGE, this.onMainMountComboxChangeHandler);
            ObjCreate.createTextField(Language.getString(70083), 220, 10, 70, 30, this, new GTextFormat(FontUtil.songtiName, 14, 15788607, true));
            ObjCreate.createBg(226, 34, 38, 38, this, ImagesConst.PackItemBg);
            this._deputyMountItem = new BaseItem();
            this._deputyMountItem.posIndex = 2;
            this._deputyMountItem.setSize(32, 32);
            this._deputyMountItem.move(229, 37);
            this._deputyMountItem.addEventListener(flash.events.MouseEvent.CLICK, this.onDeputyMountItemClickHandler);
            this._deputyMountItem.addEventListener(DragEvent.Event_Move_In, this.onDeputyMoveInMountHandler);
            this.addChild(this._deputyMountItem);
            this._deputyMountComboBox = ObjCreate.createGComboBox(190, 77, 105, 25, this.dpDeput, this);
            this._deputyMountComboBox.selectedIndex = -1;
            this._deputyMountComboBox.dropdown.setStyle("cellRenderer", MountComboBoxItemCellRender);
            this._deputyMountComboBox.prompt = Language.getString(70088);
            this._deputyMountComboBox.addEventListener(flash.events.Event.CHANGE, this.onDeputyMountComboxChangeHandler);
            ObjCreate.createBg(143, 189, 38, 38, this, ImagesConst.PackItemBg);
            this._previewMountItem = new BaseItem();
            this._previewMountItem.posIndex = 3;
            this._previewMountItem.isDragAble = false;
            this._previewMountItem.isDropAble = false;
            this._previewMountItem.setSize(32, 32);
            this._previewMountItem.move(145, 191);
            this._previewMountItem.isShowToolTip = false;
            this.addChild(this._previewMountItem);
            this._previewNameTxt = ObjCreate.createTextField("", 106, 231, 115, 20, this, GlobalStyle.textFormat6);
            this._previewNameTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._resetBtn = ObjCreate.createGButton(Language.getString(70084), 84, 261, 70, 28, this, "ButtonSpecial");
            this._extendBtn = ObjCreate.createGButton(Language.getString(70094), 173, 261, 70, 28, this, "ButtonSpecial");
            this._extendBtn.name = "extend";
            this._extendBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onBtnClickHandler);
            this._resetBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onBtnClickHandler);
            var loc1=GlobalClass.getBitmap(ImagesConst.Fire);
            loc1.x = 6;
            loc1.y = 290;
            this.addChild(loc1);
            var loc2=ObjCreate.createTextField("", 29, 296, 292, 20, this);
            loc2.autoSize = flash.text.TextFieldAutoSize.LEFT;
            loc2.htmlText = Language.getString(70095);
            loc3 = new FlowerBg(322, 76);
            loc3.y = 323;
            (loc4 = ObjCreate.createTextField("", 7, 9, 290, 63, loc3)).autoSize = flash.text.TextFieldAutoSize.LEFT;
            loc4.multiline = true;
            loc4.wordWrap = true;
            loc4.mouseWheelEnabled = false;
            loc4.htmlText = "<textFormat leading=\'5\'>" + PublicMessageConfig.instance.getMountModuleTextByName("MountExtend") + "</textFormat>";
            this.addChild(loc3);
            (loc5 = new GScrollPane()).styleName = "GScrollPane";
            loc5.verticalScrollPolicy = ScrollPolicy.ON;
            loc5.horizontalScrollPolicy = ScrollPolicy.OFF;
            loc5.width = 308;
            loc5.height = 70;
            loc5.x = 3;
            loc5.y = 1;
            loc5.source = loc4;
            loc3.addChild(loc5);
            this._spRight = new FlowerBg(213, 400);
            addChild(this._spRight);
            this._spRight.x = 325;
            ObjCreate.createBg(0, 0, 150, 24, this._spRight, ImagesConst.TileBg);
            this._stBmMountBeforExtend = ObjCreate.createBitmap("", 3, 2, this._spRight);
            var loc6=Language.getString(70089).split(",");
            var loc7=ObjCreate.createTextField(loc6[0], 9, 23, 53, 20, this._spRight);
            var loc8=ObjCreate.createTextField(loc6[1], 104, 23, 53, 20, this._spRight);
            var loc9=ObjCreate.createTextField(loc6[2], 9, 43, 53, 20, this._spRight);
            var loc10=ObjCreate.createTextField(loc6[3], 9, 63, 53, 20, this._spRight);
            var loc11=ObjCreate.createTextField(Language.getString(70203) + "：", 104, 43, 62, 20, this._spRight);
            this._expBar = new PetProcessBar(ImagesConst.GreenBar10, 144, 12);
            this._expBar.x = 56;
            this._expBar.y = 66;
            this._spRight.addChild(this._expBar);
            this._expBar.setValue(0, 0);
            var loc12;
            (loc12 = ResouceConst.getScaleBitmap(ImagesConst.SplitLine)).width = 200;
            loc12.x = 5;
            loc12.y = 84;
            this._spRight.addChild(loc12);
            ObjCreate.createBg(0, 86, 82, 24, this._spRight, ImagesConst.TileBg);
            ObjCreate.createBg(104, 87, 82, 24, this._spRight, ImagesConst.TileBg);
            this._stBmMountBaseAtrr = ObjCreate.createBitmap("", 10, 88, this._spRight);
            this._stBmMountAddAtrr = ObjCreate.createBitmap("", 108, 88, this._spRight);
            var loc13=Language.getString(70079).split(",");
            var loc14=0;
            while (loc14 < loc13.length) 
            {
                loc18 = ObjCreate.createTextField(loc13[loc14], 9, 111 + 28 * loc14, 42, 20, this._spRight);
                loc19 = ObjCreate.createTextField("", 49, 111 + 28 * loc14, 42, 20, this._spRight, GlobalStyle.textFormat2);
                this._arrBaseValue.push(loc19);
                loc20 = ObjCreate.createTextField(this._arrAttrGrow[loc14], 7, 302 + 20 * loc14, 80, 20, this._spRight);
                loc21 = ObjCreate.createTextField("", 84, 302 + 20 * loc14, 62, 20, this._spRight);
                loc22 = ObjCreate.createTextField("", 145, 302 + 20 * loc14, 62, 20, this._spRight);
                loc21.autoSize = flash.text.TextFormatAlign.CENTER;
                loc22.autoSize = flash.text.TextFormatAlign.CENTER;
                this._growStartArr.push(loc21);
                this._growForsterArr.push(loc22);
                ++loc14;
            }
            ObjCreate.createBg(100, 92, 210, 3, this._spRight, ImagesConst.Line).rotation = 90;
            var loc15;
            (loc15 = ResouceConst.getScaleBitmap(ImagesConst.SplitLine)).width = 200;
            loc15.x = 5;
            loc15.y = 272;
            this._spRight.addChild(loc15);
            ObjCreate.createBg(0, 275, 82, 24, this._spRight, ImagesConst.TileBg);
            this._stBmMoungtGrow = ObjCreate.createLoadedBitmap("", 10, 276, this._spRight);
            var loc16=ObjCreate.createLabel(Language.getString(71516), 103, 280, 60, 20, flash.text.TextFormatAlign.LEFT, this._spRight, false, GlobalStyle.color6Uint);
            var loc17=ObjCreate.createLabel(Language.getString(71509), 164, 280, 60, 20, flash.text.TextFormatAlign.LEFT, this._spRight, false, GlobalStyle.color6Uint);
            this._txLevel = ObjCreate.createTextField("", 55, 23, 60, 20, this._spRight, GlobalStyle.textFormat2);
            this._txGrade = ObjCreate.createTextField("", 150, 23, 60, 20, this._spRight, GlobalStyle.textFormat2);
            this._txSpeed = ObjCreate.createTextField("", 55, 44, 60, 20, this._spRight, GlobalStyle.textFormat2);
            this._txHuanLv = ObjCreate.createTextField("", 166, 44, 30, 20, this._spRight, GlobalStyle.textFormat2);
            this._spAttrAdd = new Object /* flash.display.Sprite */();
            this._spAttrAdd.x = 114;
            this._spAttrAdd.y = 111;
            this._spRight.addChild(this._spAttrAdd);
            this.clear();
            LoaderHelp.addResCallBack(ResFileConst.mount, this.onLoadBmResource);
            this._testMainLab = ObjCreate.createLabel("", 0, 115, 200, 20, flash.text.TextFormatAlign.CENTER, this, false, 65280);
            this._testDeputyLab = ObjCreate.createLabel("", 155, 115, 200, 20, flash.text.TextFormatAlign.CENTER, this, false, 65280);
            this._testMainRein = ObjCreate.createLabel("", 2, 137, 200, 50, flash.text.TextFormatAlign.LEFT, this, false, 65280);
            this._testDeputyRein = ObjCreate.createLabel("", 162, 137, 200, 50, flash.text.TextFormatAlign.LEFT, this, false, 65280);
            this._testMainLab.filters = [FilterConst.glowFilter];
            this._testDeputyLab.filters = [FilterConst.glowFilter];
            this._testMainRein.filters = [FilterConst.glowFilter];
            this._testDeputyRein.filters = [FilterConst.glowFilter];
            return;
        }

        public updateInfo(arg1: ItemData): void
        {
            if (arg1) 
            {
                if (this._mainMountInfo != null) 
                {
                    if (arg1.uid == this._mainMountInfo.uid) 
                    {
                        if (this._deputyMountInfo == null) 
                        {
                            this.updateDeputyByMountInfo(arg1);
                            this.onMainMountItemClickHandler(null);
                            this.clearAttr();
                        }
                    }
                    else if (this._deputyMountInfo == null) 
                    {
                        this.updateDeputyByMountInfo(arg1);
                    }
                }
                else if (this._deputyMountInfo) 
                {
                    if (arg1.uid == this._deputyMountInfo.uid) 
                    {
                        this.updateMainByMountInfo(arg1);
                        this.onDeputyMountItemClickHandler(null);
                        this.clearAttr();
                    }
                    else 
                    {
                        this.updateMainByMountInfo(arg1);
                    }
                }
                else 
                {
                    this.updateMainByMountInfo(arg1);
                }
            }
            return;
        }

        /* internal  */updateMainByMountInfo(arg1: ItemData): void
        {
            if (MountConfig.instance.isDtModel(arg1.modelId) || Cache.instance.pack.mountsPackCache.isTimeliness(arg1)) 
            {
                MsgManager.showRollTipsMsg(Language.getString(70330));
                this._mainMountComboBox.selectedIndex = -1;
                this.onMainMountItemClickHandler(null);
                return;
            }
            this._mainMountInfo = arg1;
            if (arg1) 
            {
                this._mainMountItem.dragSource = arg1;
                this._mainMountItem.itemData = arg1;
                this.setSelectedItem(arg1, this._mainMountComboBox, true);
                if (this._deputyMountInfo) 
                {
                    if (arg1.color < this._deputyMountInfo.color) 
                    {
                        MsgManager.showRollTipsMsg(Language.getString(70273));
                        this.onDeputyMountItemClickHandler(null);
                        return;
                    }
                }
            }
            this.updatePreviewByMountInfo();
            return;
        }

        /* internal  */getMountInComboIndex(arg1: ItemData): int
        {
            var loc3=null;
            var loc1=-1;
            var loc2=this._mainMountComboBox.dataProvider.toArray();
            var loc4=0;
            while (loc4 < loc2.length) 
            {
                if ((loc3 = loc2[loc4].value as ItemData) && loc3.uid == arg1.uid) 
                {
                    loc1 = loc4;
                    break;
                }
                ++loc4;
            }
            return loc1;
        }

        /* internal  */updateDeputyByMountInfo(arg1: ItemData): void
        {
            if (arg1.posType == EPlayerItemPosType._EPlayerItemPosTypeRole) 
            {
                MsgManager.showRollTipsMsg(Language.getString(71443));
                return;
            }
            if (arg1 && this._mainMountInfo) 
            {
                if (this._mainMountInfo.color < arg1.color) 
                {
                    MsgManager.showRollTipsMsg(Language.getString(70273));
                    this.onDeputyMountItemClickHandler(null);
                    return;
                }
            }
            this._deputyMountInfo = arg1;
            if (arg1) 
            {
                this._deputyMountItem.dragSource = arg1;
                this._deputyMountItem.itemData = arg1;
                this.setSelectedItem(arg1, this._deputyMountComboBox, false);
            }
            this.updatePreviewByMountInfo();
            return;
        }

        protected onMainMountItemClickHandler(arg1: Object /* flash.events.MouseEvent */=null): void
        {
            this._mainMountItem.dragSource = null;
            this._mainMountItem.itemData = null;
            this._mainMountInfo = null;
            this.updatePreviewByMountInfo();
            this._mainMountComboBox.selectedIndex = -1;
            this._mainMountComboBox.textColor = GlobalStyle.color1Uint;
            this.clearAttr();
            return;
        }

        protected onMainMoveInMountHandler(arg1: DragEvent): void
        {
            var loc2=null;
            var loc1=arg1.dragItem as BaseItem;
            if (loc1) 
            {
                if (loc1 && loc1 is BaseItem) 
                {
                    loc2 = loc1.itemData;
                    this.moveInMainMount(loc2);
                }
            }
            return;
        }

        /* internal  */moveInMainMount(arg1: ItemData): void
        {
            if (this._deputyMountInfo && arg1 && arg1.uid == this._deputyMountInfo.uid) 
            {
                this.onDeputyMountItemClickHandler(null);
            }
            this.updateMainByMountInfo(arg1);
            return;
        }

        protected onMainMountComboxChangeHandler(arg1: Object /* flash.events.Event */): void
        {
            var loc1=this._mainMountComboBox.selectedItem.value;
            this.moveInMainMount(loc1);
            return;
        }

        protected onDeputyMountItemClickHandler(arg1: Object /* flash.events.MouseEvent */=null): void
        {
            this._deputyMountItem.dragSource = null;
            this._deputyMountItem.itemData = null;
            this._deputyMountInfo = null;
            this.updatePreviewByMountInfo();
            this._deputyMountComboBox.selectedIndex = -1;
            this._deputyMountComboBox.textColor = GlobalStyle.color1Uint;
            this.clearAttr();
            return;
        }

        /* internal  */updatePreviewByMountInfo(): void
        {
            var loc1=null;
            var loc2=0;
            var loc3=null;
            if (this._mainMountInfo && this._deputyMountInfo) 
            {
                loc1 = new ItemData(this._mainMountInfo.itemCode);
                loc2 = this._mainMountInfo.itemExInfo.m_adv_lv >= this._deputyMountInfo.itemExInfo.m_adv_lv ? this._mainMountInfo.itemExInfo.m_adv_lv : this._deputyMountInfo.itemExInfo.m_adv_lv;
                loc3 = new Object();
                loc1.setItemExInfo(loc3);
                loc1.itemExInfo.m_adv_lv = loc2;
                this._previewMountItem.dragSource = loc1;
                this._previewMountItem.itemData = loc1;
                this._previewNameTxt.htmlText = ItemsUtil.getItemName(this._mainMountInfo);
                this.showAfterExtendInfos();
            }
            else 
            {
                this._previewMountItem.dragSource = null;
                this._previewMountItem.itemData = null;
                this._previewNameTxt.htmlText = "";
            }
            return;
        }

        /* internal  */showAfterExtendInfos(): void
        {
            var loc5=0;
            var loc6=null;
            var loc7=null;
            var loc8=null;
            var loc9=null;
            var loc1=Cache.instance.pack.mountsPackCache.getMountAfterExtendInfo(this._mainMountInfo, this._deputyMountInfo, this._selectedNum);
            this._txLevel.text = loc1.level;
            this._txGrade.text = loc1.grade + "☆";
            this._txSpeed.text = "+" + (loc1.speed - 100) + "%";
            this._txHuanLv.text = Cache.instance.pack.mountsPackCache.getHuanLv(this._mainMountInfo, this._deputyMountInfo).toString();
            this._expBar.setValue(loc1.exp, loc1.expTotal);
            var loc2=loc1.baseValue.length;
            var loc3=0;
            while (loc3 < loc2) 
            {
                this._arrBaseValue[loc3].text = loc1.baseValue[loc3];
                this._growStartArr[loc3].htmlText = "<font color=\'#F1FFB1\'>" + loc1.grows[loc3] + "</font>";
                this._growForsterArr[loc3].htmlText = "<font color=\'#F1FFB1\'>" + loc1.forster[loc3] + "</font>";
                ++loc3;
            }
            while (this._spAttrAdd.numChildren > 0) 
            {
                this._spAttrAdd.removeChildAt(0);
            }
            var loc4;
            (loc4 = Cache.instance.pack.mountsPackCache.getAddAttrInfo(this._mainMountInfo, this._deputyMountInfo)).sortOn("key");
            if (loc4.length > 0) 
            {
                loc5 = 0;
                while (loc5 < loc4.length) 
                {
                    loc6 = loc4[loc5] as Map<any, any> /* flash.utils.Dictionary */;
                    loc7 = "";
                    if (loc6["key"] == 12 || loc6["key"] == 13) 
                    {
                        loc7 = Language.getString(36306) + "：";
                    }
                    else 
                    {
                        loc7 = loc6["name"] + "：";
                    }
                    loc8 = ObjCreate.createTextField(loc7, 0, 20 * loc5, 60, 20, this._spAttrAdd);
                    loc9 = ObjCreate.createTextField(loc6["value"], 48, 20 * loc5, 50, 20, this._spAttrAdd, GlobalStyle.textFormat2);
                    ++loc5;
                }
            }
            this._previewNameTxt.htmlText = ItemsUtil.getItemName(this._mainMountInfo);
            this._collectValueIsUp = loc1.collectValueIsUp;
            if (Global.isDebugModle) 
            {
                this._testMainLab.text = "洗髓最高：" + this._mainMountInfo.itemExInfo.m_was_best;
                this._testDeputyLab.text = "洗髓最高：" + this._deputyMountInfo.itemExInfo.m_was_best;
                this._testMainRein.htmlText = "转生等级：" + this._mainMountInfo.itemExInfo.mount_rein_l + " 现级：" + this._mainMountInfo.itemExInfo.mount_level;
                this._testDeputyRein.htmlText = "转生等级：" + this._deputyMountInfo.itemExInfo.mount_rein_l + " 现级：" + this._deputyMountInfo.itemExInfo.mount_level;
            }
            else 
            {
                this._testMainLab.text = "";
                this._testDeputyLab.text = "";
                this._testMainRein.text = "";
                this._testDeputyRein.text = "";
            }
            return;
        }

        protected onDeputyMoveInMountHandler(arg1: DragEvent): void
        {
            var loc2=null;
            var loc1=arg1.dragItem as BaseItem;
            if (loc1) 
            {
                if (loc1 && loc1 is BaseItem) 
                {
                    loc2 = loc1.itemData;
                    this.moveInDeputyMount(loc2);
                }
            }
            return;
        }

        /* internal  */moveInDeputyMount(arg1: ItemData): void
        {
            if (this._mainMountInfo && arg1 && arg1.uid == this._mainMountInfo.uid) 
            {
                this.onMainMountItemClickHandler(null);
            }
            this.updateDeputyByMountInfo(arg1);
            return;
        }

        protected onDeputyMountComboxChangeHandler(arg1: Object /* flash.events.Event */): void
        {
            var loc1=this._deputyMountComboBox.selectedItem.value;
            this.moveInDeputyMount(loc1);
            return;
        }

        protected onBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var e: Object /* flash.events.MouseEvent */;
            var name: string;
            var closeAlert: Function;

            var loc1;
            e = arg1;
            name = (e.target as GButton).name;
            if (name != "extend") 
            {
                this.clear();
            }
            else 
            {
                if (!this._mainMountInfo || !this._deputyMountInfo) 
                {
                    MsgManager.showRollTipsMsg(Language.getString(70103));
                    return;
                }
                if (this._previewMountItem.dragSource) 
                {
                    if (ItemsUtil.isBind(this._mainMountInfo)) 
                    {
                        this.toAlertExtend();
                    }
                    else if (ItemsUtil.isBind(this._deputyMountInfo)) 
                    {
                        closeAlert = (arg1: int): void
                        {
                            if (arg1 == Alert.OK) 
                            {
                                toAlertExtend();
                            }
                            return;
                        }
                        Alert.show(Language.getString(70100), null, Alert.OK | Alert.CANCEL, null, closeAlert);
                    }
                    else 
                    {
                        this.toAlertExtend();
                    }
                }
            }
            return;
        }

        /* internal  */getMountComboDp(arg1: Array<any>, arg2: Boolean): DataProvider
        {
            var loc3=null;
            var loc1=new DataProvider();
            var loc2=arg1.length;
            var loc4=0;
            while (loc4 < loc2) 
            {
                loc3 = arg1[loc4] as ItemData;
                if (arg2) 
                {
                    loc1.addItem({"label": loc3.name, "value": loc3});
                }
                else if (loc3.posType == EPlayerItemPosType._EPlayerItemPosTypeBag) 
                {
                    loc1.addItem({"label": loc3.name, "value": loc3});
                }
                ++loc4;
            }
            return loc1;
        }

        public clear(): void
        {
            this.onMainMountItemClickHandler(null);
            this.onDeputyMountItemClickHandler(null);
            this.clearAttr();
            return;
        }

        /* internal  */clearAttr(): void
        {
            var loc1=0;
            this._txGrade.text = "";
            this._txLevel.text = "";
            this._txSpeed.text = "";
            this._txHuanLv.text = "";
            this._expBar.setValue(0, 0);
            this._previewNameTxt.text = "";
            if (this._arrBaseValue.length > 0) 
            {
                loc1 = 0;
                while (loc1 < this._arrBaseValue.length) 
                {
                    this._arrBaseValue[loc1].text = "";
                    this._growForsterArr[loc1].text = "";
                    this._growStartArr[loc1].text = "";
                    ++loc1;
                }
            }
            while (this._spAttrAdd.numChildren > 0) 
            {
                this._spAttrAdd.removeChildAt(0);
            }
            return;
        }

        public setUndressItem(arg1: Array<any>): void
        {
            var loc1=0;
            if (Cache.instance.pack.mountsPackCache.undressMountUid != "") 
            {
                loc1 = 0;
                while (loc1 < arg1.length) 
                {
                    if (Cache.instance.pack.mountsPackCache.undressMountUid == (arg1[loc1] as ItemData).uid) 
                    {
                        this.updateInfo(arg1[loc1]);
                        Cache.instance.pack.mountsPackCache.undressMountUid = "";
                        return;
                    }
                    ++loc1;
                }
            }
            return;
        }

        public mountListChange(arg1: Array<any>): void
        {
            var loc5=null;
            var loc6=null;
            if (arg1.length == 0) 
            {
                this.clear();
                return;
            }
            this.dpMian = this.getMountComboDp(arg1, true);
            this.dpDeput = this.getMountComboDp(arg1, false);
            if (this.dpMian.length == 0 && this.dpDeput.length == 0) 
            {
                this.onMainMountItemClickHandler(null);
                this.onDeputyMountItemClickHandler(null);
                this.clearAttr();
                return;
            }
            if (this.dpMian.length == 0) 
            {
                this.onMainMountItemClickHandler(null);
                this.clearAttr();
            }
            if (this.dpDeput.length == 0) 
            {
                this.onDeputyMountItemClickHandler(null);
                this.clearAttr();
            }
            if (this._mainMountComboBox.dataProvider && this._mainMountComboBox.dataProvider.length > 0 && this._mainMountComboBox.selectedIndex > -1) 
            {
                loc5 = this._mainMountComboBox.selectedItem.value;
            }
            if (this._deputyMountComboBox.dataProvider && this._deputyMountComboBox.dataProvider.length > 0 && this._deputyMountComboBox.selectedIndex > -1) 
            {
                loc6 = this._deputyMountComboBox.selectedItem.value;
            }
            var loc1=false;
            var loc2=false;
            var loc3=0;
            while (loc3 < this.dpMian.length) 
            {
                if (this._mainMountInfo && this._mainMountInfo.uid == this.dpMian.getItemAt(loc3).value.uid) 
                {
                    loc1 = true;
                    this.onMainMountItemClickHandler(null);
                    this.clearAttr();
                    this.updateMainByMountInfo(this.dpMian.getItemAt(loc3).value);
                    break;
                }
                ++loc3;
            }
            var loc4=0;
            while (loc4 < this.dpDeput.length) 
            {
                if (this._deputyMountInfo && this._deputyMountInfo.uid == this.dpDeput.getItemAt(loc4).value.uid) 
                {
                    loc2 = true;
                    this.onDeputyMountItemClickHandler(null);
                    this.clearAttr();
                    this.updateDeputyByMountInfo(this.dpDeput.getItemAt(loc4).value);
                    break;
                }
                ++loc4;
            }
            if (!loc1) 
            {
                this._mainMountInfo = null;
                this._mainMountItem.itemData = null;
                this._mainMountItem.dragSource = null;
                this._mainMountComboBox.selectedIndex = -1;
                this._mainMountComboBox.textColor = GlobalStyle.color1Uint;
                this._previewMountItem.itemData = null;
                this._previewNameTxt.text = "";
                this.clearAttr();
            }
            if (!loc2) 
            {
                this._deputyMountInfo = null;
                this._deputyMountItem.itemData = null;
                this._deputyMountItem.dragSource = null;
                this._deputyMountComboBox.selectedIndex = -1;
                this._deputyMountComboBox.textColor = GlobalStyle.color1Uint;
                this._previewMountItem.itemData = null;
                this._previewNameTxt.text = "";
                this.clearAttr();
            }
            this._mainMountComboBox.dataProvider = this.dpMian;
            this._deputyMountComboBox.dataProvider = this.dpDeput;
            if (loc5) 
            {
                this.setSelectedItem(loc5, this._mainMountComboBox, true);
            }
            if (loc6) 
            {
                this.setSelectedItem(loc6, this._deputyMountComboBox, false);
            }
            this.updatePreviewByMountInfo();
            return;
        }

        /* internal  */setSelectedItem(arg1: ItemData, arg2: GComboBox, arg3: Boolean): void
        {
            var loc1=null;
            var loc2=null;
            var loc4=null;
            if (arg3) 
            {
                loc2 = this.dpMian;
            }
            else 
            {
                loc2 = this.dpDeput;
            }
            var loc3=0;
            while (loc3 < loc2.length) 
            {
                if ((loc1 = loc2.getItemAt(loc3).value as ItemData) && loc1.uid == arg1.uid) 
                {
                    arg2.selectedIndex = loc3;
                    loc4 = ColorConfig.instance.getItemColor(arg1.color);
                    arg2.textField.setStyle("textFormat", new GTextFormat(FontUtil.songtiName, 12, loc4.intColor, null, null, null, null, null, TextAlign.CENTER));
                    break;
                }
                ++loc3;
            }
            return;
        }

        /* internal  */onClear(arg1: DataEvent): void
        {
            MsgManager.showRollTipsMsg(Language.getString(70096));
            this.clear();
            var loc1=arg1.data;
            if (loc1) 
            {
                Alert.okLabel = Language.getString(70248);
                Alert.buttonWidth = 68;
                Alert.showCloseBtn = false;
                Alert.show(HTMLUtil.addColor(Language.getString(70249), GlobalStyle.color1), null, Alert.OK, null, this.onRreshAlertHandler);
            }
            return;
        }

        /* internal  */onRreshAlertHandler(arg1: int): void
        {
            if (arg1 == Alert.OK) 
            {
                GameManager.instance.popupWindow(ModuleType.Pack);
            }
            return;
        }

        /* internal */ /* var */_deputyBox: GCheckBox;

        /* internal */ /* var */_selectedNum: int;

        /* internal */ /* var */_collectValueIsUp: Boolean;

        /* internal */ /* var */_growStartArr: Array<any>;

        /* internal */ /* var */_growForsterArr: Array<any>;

        /* internal */ /* var */_previewNameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_testMainLab: GLabel;

        /* internal */ /* var */_testDeputyLab: GLabel;

        /* internal */ /* var */_testMainRein: GLabel;

        /* internal */ /* var */_testDeputyRein: GLabel;

        /* internal */ /* var */dpMian: DataProvider;

        /* internal */ /* var */dpDeput: DataProvider;

        /* internal */ /* var */_mainMountComboBox: GComboBox;

        /* internal */ /* var */_arrAttrGrow: Array<any>;

        /* internal */ /* var */_deputyMountComboBox: GComboBox;

        /* internal */ /* var */_mainMountItem: BaseItem;

        /* internal */ /* var */_deputyMountItem: BaseItem;

        /* internal */ /* var */_previewMountItem: BaseItem;

        /* internal */ /* var */_extendBtn: GButton;

        /* internal */ /* var */_resetBtn: GButton;

        /* internal */ /* var */_expBar: PetProcessBar;

        /* internal */ /* var */_growsBar: MountGrowBars;

        /* internal */ /* var */_mainMountInfo: ItemData;

        /* internal */ /* var */_deputyMountInfo: ItemData;

        /* internal */ /* var */_txLevel: Object /* flash.text.TextField */;

        /* internal */ /* var */_txGrade: Object /* flash.text.TextField */;

        /* internal */ /* var */_txSpeed: Object /* flash.text.TextField */;

        /* internal */ /* var */_txHuanLv: Object /* flash.text.TextField */;

        /* internal */ /* var */_arrBaseValue: Array<any>;

        /* internal */ /* var */_stBmMoungtGrow: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_spRight: FlowerBg;

        /* internal */ /* var */_spAttrAdd: Object /* flash.display.Sprite */;

        /* internal */ /* var */_stBmMountExtendBg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_stBmMountBeforExtend: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_stBmMountBaseAtrr: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_stBmMountAddAtrr: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_stWashSelectTx: Object /* flash.text.TextField */;

        /* internal */ /* var */_mainBox: GCheckBox;
    }
